home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / or / orn-util.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  1.7 KB  |  96 lines

  1. /* orn-util.c: utility routines for ORNames */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/or/RCS/orn-util.c,v 6.0 1991/12/18 20:23:08 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/or/RCS/orn-util.c,v 6.0 1991/12/18 20:23:08 jpo Rel $
  9.  *
  10.  * $Log: orn-util.c,v $
  11.  * Revision 6.0  1991/12/18  20:23:08  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16. #include "util.h"
  17. #include "or.h"
  18. #include "IOB-types.h"
  19. #include "MTA-types.h"
  20. #include "Ext-types.h"
  21. #include "extension.h"
  22.  
  23. #define STR2QB(s)    str2qb(s, strlen(s), 1)
  24.  
  25. void ORName_free (orn)
  26. ORName *orn;
  27. {
  28.     if (orn == NULLORName)
  29.         return;
  30.  
  31.     if (orn -> on_or)
  32.         or_free (orn->on_or);
  33.     if (orn -> on_dn)
  34.         dn_free (orn -> on_dn);
  35.     free ((char *)orn);
  36. }
  37.  
  38. int or_append (tree, new)
  39. OR_ptr    *tree;
  40. OR_ptr    new;
  41. {
  42.     OR_ptr    tn;
  43.  
  44.     tn = or_add (*tree, new, 0);
  45.     if (tn == NULLOR) {
  46.         PP_LOG (LLOG_EXCEPTIONS, ("or_add failed on node %s",
  47.                       new -> or_value));
  48.         return NOTOK;
  49.     }
  50.     *tree = tn;
  51.     return OK;
  52. }
  53.  
  54.  
  55. struct qbuf *or_getttx (val, enc)
  56. char    *val;
  57. int    enc;
  58. {
  59.     char *cp;
  60.  
  61.     switch (enc) {
  62.         case OR_ENC_TTX:
  63.         case OR_ENC_TTX_AND_OR_PS:
  64.         if ((cp = index (val, '*')) == NULLCP) {
  65.             PP_LOG (LLOG_EXCEPTIONS,
  66.                 ("Missing * in T.61 encoding for %s", val));
  67.             return NULL;
  68.         }
  69.         return or_t61decode (cp + 1);
  70.         default:
  71.         PP_LOG (LLOG_EXCEPTIONS,
  72.             ("Not a TTX encoding"));
  73.         return NULL;
  74.     }
  75. }
  76.  
  77. struct qbuf *or_getps (val, enc)
  78. char    *val;
  79. int    enc;
  80. {
  81.     char *cp;
  82.  
  83.     switch (enc) {
  84.         case OR_ENC_PS:
  85.         return STR2QB (val);
  86.         case OR_ENC_TTX_AND_OR_PS:
  87.         if ((cp = index(val, '*')) == NULLCP)
  88.             return STR2QB (val);
  89.         else
  90.             return str2qb (val, cp - val, 1);
  91.         default:
  92.         PP_LOG (LLOG_EXCEPTIONS, ("getps called with bad encoding"));
  93.         return NULL;
  94.     }
  95. }
  96.